package com.job.sun.HomeWork0717;

import java.util.Random;

/**
 * @author 张春阳
 * @version 1.0
 * @since 2022-07-18 10:41:20
 */
public class StringBuffer03 {
    public static void main(String[] args) {
    //练习
        //插入
        String str ="ABCDEFGHIJKLMN";
        Random random = new Random();
        long t1 = System.currentTimeMillis();
        System.out.println(t1);//1658114748151
        StringBuffer sbf =new StringBuffer(String.valueOf(t1));
        int num =2;
        for (int i=0;i<5;i++){
            //
            sbf.insert(num, str.charAt(random.nextInt(str.length())));
            num+=3;
        }
        String string = sbf.toString();
        System.out.println(string);
        //提取
        String str2 = "dd5424535s4d";
        StringBuffer sbf2 =new StringBuffer(str2);
        StringBuffer sbf3 =new StringBuffer();
        for(int i=0;i<str2.length();i++){
            char a=sbf2.charAt(i);
            if(Character.isDigit(a)){
                sbf3.append(a);
            }

        }
        int anInt = Integer.parseInt(sbf3.toString());
        System.out.println(anInt);
    }
}